package vn.lumi.smarthome.io.model;

public class Device {
	
//	public static final int DEVICE_TYPE_ONOFF=0;
//	public static final int DEVICE_TYPE_VALUECHANGE=DEVICE_TYPE_ONOFF+1;
//	public static final int DEVICE_TYPE_CEILING=DEVICE_TYPE_VALUECHANGE+1;
//	public static final int DEVICE_TYPE_NONGLANH=DEVICE_TYPE_CEILING+1;
//	public static final int DEVICE_TYPE_AIR_CONDITIONER=DEVICE_TYPE_NONGLANH+1;
//	public static final int DEVICE_TYPE_BLIND_HORIZONTAL=DEVICE_TYPE_AIR_CONDITIONER+1;
//	public static final int DEVICE_TYPE_BLIND_VERTICAL=DEVICE_TYPE_BLIND_HORIZONTAL+1;
//	public static final int DEVICE_TYPE_ROLLING_DOORS=DEVICE_TYPE_BLIND_VERTICAL+1;
	
	public static final int DEVICE_TYPE_LIGHT=1;
	public static final int DEVICE_TYPE_DIMMER=2;
	public static final int DEVICE_TYPE_BLIND=3;
	public static final int DEVICE_TYPE_AIRCON=5;
	public static final int DEVICE_TYPE_HEATER=6;
	public static final int DEVICE_TYPE_RGB=7;
	public static final int DEVICE_TYPE_FAN=8;
	
	
	private int id;
	private int type_id;
	private int room_id;
	private String name;
	private int state_id;
	private boolean isControl=false;
	
	/**
	 * Duoc su dung khi them + sua canh
	 */
	private boolean isTurnOn=false;
	
	/**
	 * Duoc su dung khi them + sua canh
	 */
	private boolean isSelected=false;
	
	private DeviceState deviceState;
	
	public Device(int id, int type_id, int room_id, String name, int state_id,DeviceState state,boolean isControl) {
		super();
		this.id = id;
		this.type_id = type_id;
		this.room_id = room_id;
		this.name = name;
		this.state_id = state_id;
		deviceState=state;
		this.isControl=isControl;
	}
	public Device() {
	}
	
	
	public boolean isTurnOn() {
		return isTurnOn;
	}
	public void setTurnOn(boolean isTurnOn) {
		this.isTurnOn = isTurnOn;
	}
	public boolean isSelected() {
		return isSelected;
	}
	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}
	public boolean isControl() {
		return isControl;
	}
	public void setControl(boolean isControl) {
		this.isControl = isControl;
	}
	public DeviceState getDeviceState() {
		return deviceState;
	}
	public void setDeviceState(DeviceState deviceState) {
		this.deviceState = deviceState;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getType_id() {
		return type_id;
	}
	public void setType_id(int type_id) {
		this.type_id = type_id;
	}
	public int getRoom_id() {
		return room_id;
	}
	public void setRoom_id(int room_id) {
		this.room_id = room_id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getState_id() {
		return state_id;
	}
	public void setState_id(int state_id) {
		this.state_id = state_id;
	}
	
	public interface OnActiveListener{
		public void onActive(Device device,boolean value);
	}
	
	public interface OnChangeSpeedListener{
		public void onChangeSpeed(Device device,int speed);
	}
	
	public static enum TYPE{
		LIGHT
	}
	
	/**
	 * Luu y dac biet: Type cua device phai bat dau=0, vi trong phan adapter co yeu cau: getItemViewType< getViewTypeCount
	 */
	public static final int NUM_LAYOUT_TYPE=4;
	public static final int TYPE_LAYOUT_ONOFF=0;
	public static final int TYPE_LAYOUT_DIMMER=TYPE_LAYOUT_ONOFF+1;
	public static final int TYPE_LAYOUT_BLIND=TYPE_LAYOUT_DIMMER+1;
	public static final int TYPE_LAYOUT_RGB=TYPE_LAYOUT_BLIND+1;
	
	public static int getLayoutType(int type){
		switch (type) {
		case DEVICE_TYPE_AIRCON:
		case DEVICE_TYPE_HEATER:
		case DEVICE_TYPE_LIGHT:
		return TYPE_LAYOUT_ONOFF;
		
		case DEVICE_TYPE_FAN:
		case DEVICE_TYPE_DIMMER:
		return TYPE_LAYOUT_DIMMER;
		
		case DEVICE_TYPE_BLIND:
		return TYPE_LAYOUT_BLIND;
		
		case DEVICE_TYPE_RGB:
			return TYPE_LAYOUT_RGB;

		default:
			return 0;
		}
	}
	
}

